#pragma once
#include <iostream>
#include <string>
#include <fcntl.h>
#define Change(v) (struct sockaddr *)(v)
#define Die(code)   \
    do              \
    {               \
        exit(code); \
    } while (0)

enum
{
    SCOKET_ERR = 1,
    BIND_ERR,
    USAGE_ERR,
    Listen_ERR,
    EPOLL_CREATE_ERROR,
    EPOLL_WAIT_ERROR,
    EPOLL_CTRL_ERROR
};

class Command
{
public:
    std::string Execute(std::string cmdstr)
    {
        return cmdstr;
    }
};

int gdefaultsockfd = -1;

void SetNoBlack(int sockfd)
{
    int f = fcntl(sockfd, F_GETFL);
    if (f < 0)
    {
        return;
    }
    fcntl(sockfd, F_SETFD, f | O_NONBLOCK);
}